package com.tdam2014.grupo3.tasks;

import android.os.AsyncTask;

import com.tdam2014.grupo3.entities.People;
import com.tdam2014.grupo3.entities.Photo;
import com.tdam2014.grupo3.entities.PhotoSet;
import com.tdam2014.grupo3.utils.ImagesUtils;

public class DeletePeopleImagesTask extends AsyncTask<People, Void, Void> {
	
	public DeletePeopleImagesTask() {
		super();
	}
	
	@Override
	protected Void doInBackground(People... params) {
		People people = params[0];
		
		String path = ImagesUtils.PROFILES_PATH + people.getNsid() + ".jpg";
        ImagesUtils.deleteImage(path);
        
        for (PhotoSet photoSet : people.getPhotoSets()) {
        	for (Photo photo : photoSet.getPhotos()) {
        		path = ImagesUtils.THUMBS_PATH + photoSet.getId() + "_" + photo.getId() + ".jpg";
        		ImagesUtils.deleteImage(path);
        	}
        }
        
        return null;
	}
}
